<%@ page language="java" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/jsp/pub/include.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>项目绩效</title>
    <link href="<%=request.getContextPath() %>/css/admin.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/common.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.form.js"></script>
    <script type="text/javascript">

        //弹出一个输入框，输入一段文字，可以提交
        function prom(id) {
            var name = prompt("请输入取消原因！！！", ""); //将输入的内容赋给变量 name ，

            //这里需要注意的是，prompt有两个参数，前面是提示的话，后面是当对话框出来后，在对话框里的默认值
            if (name)//如果返回的有内容
            {
                firm(id,name)
            }

        }


        function firm(id,name) {
            //利用对话框返回的值 （true 或者 false）
            if (confirm("提交后将无法在更改基础信息，马上提交吗？")) {
                check(id,name);
            }
        }

        function check(id,name){
            var url = getRootPath()+"/source/cancelworkorder";
            var   status = "4";

            var para ={
                'id' :id,
                'status':status,
                'statustr':name
            }
//            alert(url);
            $.ajax({
                cache:false,
                type:"POST",
                url: url,
                dataType:"json",
                data:para,
                error:function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                },
                success:function(returndata){
                    alert(returndata.data.message);
                    if(returndata.data.suc){
                        window.location.href= getRootPath()+"/source/workorder?m=list";
                    }else{

                    }
                }
            });
        }

        function show(id){
            var msg = "您真的确定要取消吗？\n\n请确认！";
            if (confirm(msg)==true){
                var  url=getRootPath()+"/source/delworkorder?m=del&id="+id;
                $.ajax({
                    type:"GET",
                    url: url,
                    success:function(returndata){
                        var rdata = returndata;
                        alert(rdata.data.message);
                        if(rdata.data.suc){
                            window.location.href= getRootPath()+"/source/workorder?m=list";
                        }else{
                            alert(rdata.data.message);
                        }
                    }
                });
            }
        }
        function del(id){

            location=getRootPath()+"/source/delworkorder?m=del&id="+id;
//            $.ajax({
//                cache:false,
//                type:"GET",
//                url: url,
//                error:function(XMLHttpRequest, textStatus, errorThrown) {
//                    alert(XMLHttpRequest.status);
//                },
//                success:function(returndata){
//                    if(returndata.data.suc){
//                        window.location.href= getRootPath()+"/admin/index";
//                    }else{
//                        alert(returndata.data.message);
//                    }
//                }
//            });
        }
        function search(){

            var key = $("#key").val();
            var url = "<c:url value="/source/workorder?m=list"/>";
            if(key!=""){
                url+="&key="+key;
            }else{
                alert("查询不能为空");
            }

            location=url;
        }
        function addproject(){

            var url = "<c:url value="/source/workorder?m=add"/>";
            location=url;
        }

        function downexcel(){

            location='${downexcel}';
        }
        function changeselect(){
            var url='<c:url value="/source/mine?m=list"/>';

            if($("#dapart").val()!=""){
                url+='&dapart='+$("#dapart").val();
            }
            if($("#jidu").val()!=""){
                url+='&jidu='+$("#jidu").val();
            }
            if($("#userid").val()!="0"){
                url+='&userid='+$("#userid").val();
            }

            location=url;
        }
    </script>
</head>
<body>
<div class="content">
    <jsp:include page="../pub/top.jsp"></jsp:include>
    <!--头部结束-->
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td class="left" valign="top">
                <jsp:include page="../pub/left_source.jsp"></jsp:include>
            </td>
            <td valign="top">
                <div id="c01">
                    <dl>
                        <dt style="padding-right:30px;">部门：
                            <select class="sheng" name="dapart" id="dapart"  onchange="changeselect()">
                                <option value="0">选择部门</option>
                                <c:forEach items="${dapartList}" var="dapart">
                                    <option value="${dapart.code}" ${dapart.code==param.dapart?'selected=selected':''}><c:out value="${dapart.value}"/></option>
                                </c:forEach>
                            </select>

                        </dt>
                        <dt style="padding-right:30px;">员工：
                            <select id="userid" name="userid" style="width:200px;" onchange="changeselect()">
                                <option value="0">选择执行人</option>
                                <c:forEach items="${userList}" var="user">
                                    <option value="${user.id}" ${user.id == param.userid?'selected=selected':''}><c:out value="${user.username}"/></option>
                                </c:forEach>
                            </select>

                        </dt>

                        <%--<dt >工单名:<input type="text" class="key" id="key" name="key"/> </dt>--%>
                        <%--<dd style="padding-right:30px;"><input type="button" value="查询" class="chaxun" onclick="search()"/></dd>--%>
                        <%--<c:if test="${sessionScope.user.permission.code =='0'}">--%>
                            <%--<dd ><input type="button" value="新增工单" class="chaxun" onclick="addproject()"/></dd>--%>
                             <%--&lt;%&ndash;<dd style="margin-left:50px;padding-right:30px;"><input type="button" value="下载列表"  class="chaxun" onclick="downexcel()"/></dd>&ndash;%&gt;--%>
                        <%--</c:if>--%>
                        <dt style="padding-right:30px;">时间选择：
                            <select id="jidu" name="jidu" style="width:100px;" onchange="changeselect()">
                                <option value="0" ${0 == param.jidu?'selected=selected':''}>全部</option>
                                <option value="1" ${1 == param.jidu?'selected=selected':''}>本月</option>
                                <option value="2" ${2 == param.jidu?'selected=selected':''}>1月前</option>
                                <option value="3" ${3 == param.jidu?'selected=selected':''}>2月前</option>
                                <option value="4" ${4 == param.jidu?'selected=selected':''}>3月前</option>
                            </select>

                        </dt>
                            <dd style="margin-left:20px; "><input type="button" value="下载列表"  class="chaxun" onclick="downexcel()"/></dd>
                    </dl>
                    <table width="99%" border="0" cellpadding="0" cellspacing="1" bgcolor="#dae2e5">
                        <tr>
                            <td width="5%" height="30" bgcolor="#e5edfa" align="center">序号</td>
                            <td width="10%" height="30" bgcolor="#e5edfa" align="center" >工单名称</td>
                            <td width="10%" height="30" bgcolor="#e5edfa" align="center" >所属项目</td>
                            <td width="5%" height="30" bgcolor="#e5edfa" align="center">执行部门</td>
                            <td width="5%" height="30" bgcolor="#e5edfa" align="center">执行人</td>
                            <td width="10%" height="30" bgcolor="#e5edfa" align="center">开始时间</td>
                            <td width="10%" height="30" bgcolor="#e5edfa" align="center" >截止时间</td>
                            <td width="10%" height="30" bgcolor="#e5edfa" align="center" >完成时间</td>
                            <td width="5%" height="30" bgcolor="#e5edfa" align="center" >当前状态</td>

                        </tr>
                        <c:choose>
                            <c:when test="${not empty workorderList}">
                                <c:forEach items="${workorderList}" var="workorder" varStatus="vs">
                                    <tr>
                                        <td height="30" bgcolor="#FFFFFF" align="center">
                                            <input type="hidden" name="id" value="${workorder.id}"/>
                                            <c:out value="${vs.index+1}"/>
                                        </td>

                                        <td height="30" bgcolor="#FFFFFF" align="center" style="padding-left:10px;">
                                            <c:out value="${workorder.name}"/>
                                                <%--<a href="<c:url value="/clazz/view.do?id=${clazz.id}"/>" target="_blank"><c:out value="${clazz.name}"/></a>--%>
                                        </td>
                                        <td height="30" bgcolor="#FFFFFF" align="center" style="padding-left:10px;">
                                            <a href="<c:url value="/source/projectcheck?m=check&id=${workorder.project.id}"/>"><c:out value="${workorder.project.name}"/></a>
                                                <%--<a href="<c:url value="/clazz/view.do?id=${clazz.id}"/>" target="_blank"><c:out value="${clazz.name}"/></a>--%>
                                        </td>
                                        <td height="30" bgcolor="#FFFFFF" align="center" style="padding-left:10px;">
                                            <c:out value="${workorder.depart.value}"/>
                                                <%--<a href="<c:url value="/clazz/view.do?id=${clazz.id}"/>" target="_blank"><c:out value="${clazz.name}"/></a>--%>
                                        </td>
                                        <td height="30" bgcolor="#FFFFFF" align="center" style="padding-left:10px;">
                                            <c:out value="${workorder.user.username}"/>
                                                <%--<a href="<c:url value="/clazz/view.do?id=${clazz.id}"/>" target="_blank"><c:out value="${clazz.name}"/></a>--%>
                                        </td>
                                        <td height="30" bgcolor="#FFFFFF" align="center">
                                            <c:out value="${workorder.starttime}"/>
                                                <%--<c:out value="${clazz.industry}"/>--%>
                                        </td>
                                        <td height="30" bgcolor="#FFFFFF" align="center">
                                            <c:out value="${workorder.excuttime}"/>
                                                <%--<c:out value="${clazz.industry}"/>--%>
                                        </td>
                                        <td height="30" bgcolor="#FFFFFF" align="center">
                                            <c:out value="${workorder.finishtime}"/>
                                                <%--<c:out value="${clazz.industry}"/>--%>
                                        </td>
                                        <td height="30" bgcolor="#FFFFFF" align="center">
                                            <c:if test="${workorder.status.code == 1}">
                                                <font color="yellow">
                                                    <c:out value="${workorder.status.value}"/>
                                                </font>
                                            </c:if>
                                            <c:if test="${workorder.status.code == 2}">
                                                <font color="green">
                                                    <c:out value="${workorder.status.value}"/>
                                                </font>
                                            </c:if>
                                            <c:if test="${workorder.status.code == 3}">
                                                <font color="blue">
                                                    <c:out value="${workorder.status.value}"/>
                                                </font>
                                            </c:if>
                                            <c:if test="${workorder.status.code == 4}">
                                                <font color="red">
                                                    <c:out value="${workorder.status.value}"/>
                                                </font>
                                            </c:if>
                                                <%--<c:out value="${clazz.industry}"/>--%>
                                        </td>
                                    </tr>
                                </c:forEach>
                            </c:when>
                            <c:otherwise>
                                <tr>
                                    <td colspan="10" height="30" bgcolor="#ffffff" align="center">暂无数据</td>
                                </tr>
                            </c:otherwise>
                        </c:choose>
                    </table>
                    <jsp:include page="/WEB-INF/jsp/pub/page.jsp"></jsp:include>

                    <%--<p><input type="checkbox" onclick="selectAll(this)"/> 全选 --%>
                    <%--<input type="button" value="删除" class="shanchu" onclick="del(0)"/></p>--%>
                    <%--<jsp:include page="/WEB-INF/jsp/pub/page.jsp"></jsp:include>--%>
                </div>
                <br />
                <br />
            </td>
        </tr>
    </table>
    <jsp:include page="../pub/foot.jsp"></jsp:include>
</div>
</body>
</html>
